home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / Amiga_Mail_Vol2 / Archives / Plain / mj91 / ASL / FilePat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-12  |  4.9 KB  |  132 lines

  1. ;/* filepat.c - Execute me to compile me with SASC 5.10
  2. LC -b1 -cfistq -v -y -j73 filepat.c
  3. Blink FROM LIB:c.o,filepat.o TO filepat LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5. */
  6.  
  7. /*(c)  Copyright 1991 Commodore-Amiga, Inc.   All rights reserved.
  8. The information contained herein is subject to change without notice,
  9. and is provided "as is" without warranty of any kind, either expressed
  10. or implied.  The entire risk as to the use of this information is
  11. assumed by the user.
  12. */
  13.  
  14. #include <clib/asl_protos.h>
  15. #include <clib/exec_protos.h>
  16. #include <clib/intuition_protos.h>
  17. #include <clib/alib_stdio_protos.h>
  18. #include <workbench/startup.h>
  19. #include <intuition/intuition.h>
  20. #include <intuition/screens.h>
  21. #include <graphics/displayinfo.h>
  22. #include <exec/libraries.h>
  23.  
  24. #ifdef LATTICE
  25. int CXBRK(void) { return(0); }  /* Disable Lattice CTRL/C handling */
  26. int chkabort(void) { return(0); }  /* really */
  27. #endif
  28.  
  29. UBYTE *vers = "\0$VER: filepat 1.0";
  30.  
  31. void main(void);
  32.  
  33. struct Library *AslBase;
  34. struct IntuitionBase *IntuitionBase;
  35. struct Screen *screen;
  36. struct Window *window;
  37.  
  38. struct WBArg *wbargs;
  39.  
  40. LONG x;
  41.  
  42.  
  43. void main()
  44. {
  45.  
  46.     struct FileRequester *fr;
  47.  
  48.     if (AslBase = OpenLibrary("asl.library", 36L))
  49.     {
  50.         if (IntuitionBase = (struct IntuitionBase *)
  51.                 OpenLibrary("intuition.library", 36L))
  52.         {
  53.             if (screen = (struct Screen *)OpenScreenTags(NULL, 
  54.                     SA_DisplayID, HIRESLACE_KEY,
  55.                     SA_Title, "ASL Test Screen",
  56.                     TAG_END))
  57.             {
  58.                 if (window = (struct Window *)OpenWindowTags(NULL, 
  59.                         WA_CustomScreen, screen, 
  60.                         WA_Title, "ASL Test Window", 
  61.                         WA_Flags, WINDOWDEPTH | WINDOWDRAG,
  62.                         TAG_END))
  63.                 {
  64.                     if (fr = (struct FileRequester *)
  65.                         AllocAslRequestTags(ASL_FileRequest, 
  66.                             ASL_Hail, (ULONG)"RKM File Requester, FilePat",
  67.                             ASL_Dir,  (ULONG)"libs:",
  68.                             ASL_File, (ULONG)"asl.library",
  69.  
  70.                             /* The initial pattern string for the 
  71.                             ** pattern gadget.
  72.                             */
  73.                             ASL_Pattern, (ULONG)"~(rexx#?|math#?)",
  74.                             
  75.                             /* turn on multiselection and the pattern
  76.                             ** matching gadget.
  77.                             */
  78.                             ASL_FuncFlags, FILF_MULTISELECT | FILF_PATGAD,
  79.                             
  80.                             /* This requester is associated with this
  81.                             ** window (and uses its message port). 
  82.                             */
  83.                             ASL_Window, window,
  84.                             TAG_DONE))
  85.                     {
  86.                         /* Application code body...*/
  87.                         
  88.                         /* Put up file requester */
  89.                         if (AslRequest(fr, 0L))
  90.                         {
  91.                             /* If the file requester's rf_NumArgs field
  92.                             ** is not zero, the user multiselected. The
  93.                             ** number of files is stored in rf_NumArgs.
  94.                             */
  95.                             if (fr->rf_NumArgs)
  96.                             {
  97.                                 /* rf_ArgList is an array of WBArg structures
  98.                                 ** (defined in <workbench/startup.h>).  
  99.                                 ** Each entry in the WBArg array corresponds
  100.                                 ** to one of the files the user selected
  101.                                 ** (the entries are in alphabetical order).
  102.                                 */ 
  103.                                 wbargs = fr->rf_ArgList;
  104.                                 
  105.                                 /* The user multiselected, step through
  106.                                 ** the list of selected files. 
  107.                                 */
  108.                                 for ( x=0;  x < fr->rf_NumArgs;  x++ )
  109.                                     printf("Argument %d - %s%s\n", x, 
  110.                                         fr->rf_Dir, wbargs[x].wa_Name);
  111.                             }
  112.                             else
  113.                                 /* The user didn't multiselect, use the 
  114.                                 ** normal way to get the file name.
  115.                                 */
  116.                                 printf("%s%s\n", fr->rf_Dir, fr->rf_File);
  117.                         }
  118.                         /* More application code body... */
  119.  
  120.                         /* Done with the FileRequester, better return it */
  121.                         FreeAslRequest(fr);
  122.                     }
  123.                     CloseWindow(window);
  124.                 }
  125.                 CloseScreen(screen);
  126.             }
  127.             CloseLibrary(IntuitionBase);
  128.         }
  129.         CloseLibrary(AslBase);
  130.     }
  131. }
  132.